<template>
  <div style="width: 100%; height: 100%" ref="chart"></div>
</template>

<script>
import CommonMixin from "../mixins/commonMixin";
export default {
  name: "v-chart",
  mixins: [CommonMixin],
  methods: {
    init() {
      if (!window._charts) {
        window._charts = {};
      }
      this.$nextTick(() => {
        window._charts[this.id] = window.echarts.init(this.$refs.chart);

        window._charts[this.id].setOption(this.config, true);
      });
    },
    update() {
      window._charts[this.id].setOption(this.config, true);
    },
    resize() {
      window._charts[this.id].resize();
    },
    destroy() {
      if (window._charts[this.id]) {
        window._charts[this.id].dispose();
        window._charts[this.id] = null;
      }
    },
  },
};
</script>

<style scoped></style>
